/**
 * author: zhou
 * date: 2017.10.23
 * description: 班级模型
 * {
 *      name: 班级名称
 *      schoolId: 所属学校id
 *      gradeId: 所属年级id
 *      subjectIds: 绑定科目id(数组)
 *      studentsCount: 学生数量
 * }
 */

const mongoose = require('mongoose');

const classSchema = new mongoose.Schema({
    name: { type: String, required: true },
    schoolId: { type: mongoose.Schema.Types.ObjectId, ref: 'School', required: true },
    gradeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Grade', required: true },
    subjectIds: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Subject', required: true }],
    studentsCount: { type: Number, default: 0 },
    createDate: { type: Date, default: Date.now }
});

module.exports = mongoose.model('Class', classSchema, 'schools.settings.classes');